/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.farmcode.api.types.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author oiprado
 */
@Entity
@Table(name = "FC_DATABASE")
@NamedQueries({
  @NamedQuery(name = "Database.findAll", query = "SELECT d FROM Database d")})
public class Database implements Serializable {
  private static final long serialVersionUID = 1L;
  @Id
  @Basic(optional = false)
  @NotNull
  @Column(name = "ID")
  private Long id;
  @Size(max = 50)
  @Column(name = "NAME")
  private String name;
  @OneToMany(mappedBy = "database",fetch= FetchType.EAGER)
  private List<ColumnByDatabase> columnByDatabaseList;

  public Database() {
  }

  public Database(Long id) {
    this.id = id;
  }

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public List<ColumnByDatabase> getColumnByDatabaseList() {
    return columnByDatabaseList;
  }

  public void setColumnByDatabaseList(List<ColumnByDatabase> columnByDatabaseList) {
    this.columnByDatabaseList = columnByDatabaseList;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (id != null ? id.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Database)) {
      return false;
    }
    Database other = (Database) object;
    if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "com.farmcode.api.types.model.Database[ id=" + id + " ]";
  }
  
}
